from common.d_shuolds import clock
from requestMethod.mallHomeApi import Req_api,mrjbusC



class pre_mallHome():

    def __init__(self):
        self.status = "通过"

    def SpuDetailState(self):
        """
        验证商品详情状态
        :uri : /front/p/newGoodsSpu/newGoodsSpuDetail
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.newGoodsSpuDetail()
        state = res.status_code
        assert state == 200,"/front/p/newGoodsSpu/newGoodsSpuDetail 校验接口状态码为200，校验失败,实际状态码： %s" % state


    def SpuDetailTime(self):
        """
        验证商品详情响应时长
        :uri : /front/p/newGoodsSpu/newGoodsSpuDetail
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.newGoodsSpuDetail()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/newGoodsSpu/newGoodsSpuDetail 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime


    def SpuDetailData(self):
        """
        验证商品详情响应数据
        :uri : /front/p/newGoodsSpu/newGoodsSpuDetail
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.newGoodsSpuDetail()
        assert "spuName" in res.text,"/front/p/newGoodsSpu/newGoodsSpuDetail 校验接口存在spuName数据，校验失败,实际响应数据：\n%s" % res.text

    def homePageState(self):
        """
        验证首页接口状态
        :uri : /front/p/mallHome/main
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.homePage()
        state = res.status_code
        assert state == 200,"/front/p/mallHome/main 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def homePageTime(self):
        """
        验证首页接口响应时长
        :uri : /front/p/mallHome/main
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.homePage()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/mallHome/main 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def homePageData(self):
        """
        验证首页接口响应数据
        :uri : /front/p/mallHome/main
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.homePage()
        assert "bannerName" in res.text,"/front/p/mallHome/main 校验接口存在bannerName数据，校验失败,实际响应数据：\n%s" % res.text

    def topProductsState(self):
        """
        验证商城首页平台推荐接口状态
        :uri : /front/p/mallHome/topProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.topProducts()
        state = res.status_code
        assert state == 200,"/front/p/mallHome/topProducts 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def topProductsTime(self):
        """
        验证商城首页平台推荐接口响应时长
        :uri : /front/p/mallHome/topProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.topProducts()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/mallHome/topProducts 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def topProductsData(self):
        """
        验证商城首页平台推荐接口响应数据
        :uri : /front/p/mallHome/topProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.topProducts()
        assert "sellPrice" in res.text,"/front/p/mallHome/topProducts 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def weeklyProductsState(self):
        """
        验证本周上新接口状态
        :uri : /front/p/mallHome/weeklyProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.weeklyProducts()
        state = res.status_code
        assert state == 200,"/front/p/mallHome/weeklyProducts 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def weeklyProductsTime(self):
        """
        验证本周上新接口响应时长
        :uri : /front/p/mallHome/weeklyProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.weeklyProducts()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/mallHome/weeklyProducts 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def weeklyProductsData(self):
        """
        验证本周上新接口响应数据
        :uri : /front/p/mallHome/weeklyProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.weeklyProducts()
        assert "sellPrice" in res.text,"/front/p/mallHome/weeklyProducts 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def popularProductsState(self):
        """
        验证口碑爆款接口状态
        :uri : /front/p/mallHome/popularProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.popularProducts()
        state = res.status_code
        assert state == 200,"/front/p/mallHome/popularProducts 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def popularProductsTime(self):
        """
        验证口碑爆款接口响应时长
        :uri : /front/p/mallHome/popularProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.popularProducts()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/mallHome/popularProducts 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def popularProductsData(self):
        """
        验证口碑爆款接口响应数据
        :uri : /front/p/mallHome/popularProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.popularProducts()
        assert "sellPrice" in res.text,"/front/p/mallHome/popularProducts 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def subsidyProductsState(self):
        """
        验证会员福利社接口状态
        :uri : /front/p/mallHome/subsidyProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.subsidyProducts()
        state = res.status_code
        assert state == 200,"/front/p/mallHome/subsidyProducts 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def subsidyProductsTime(self):
        """
        验证会员福利社接口响应时长
        :uri : /front/p/mallHome/subsidyProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.subsidyProducts()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/mallHome/subsidyProducts 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def subsidyProductsData(self):
        """
        验证会员福利社接口响应数据
        :uri : /front/p/mallHome/subsidyProducts
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.subsidyProducts()
        assert "sellPrice" in res.text,"/front/p/mallHome/subsidyProducts 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def getHomeBrandDetailState(self,brandId=None):
        """
        验证品牌页-本月推荐接口状态
        :uri : /front/p/homeBrand/getHomeBrandDetail
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.getHomeBrandDetail(brandId=brandId)
        state = res.status_code
        assert state == 200,"/front/p/homeBrand/getHomeBrandDetail 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def getHomeBrandDetailTime(self,brandId=None):
        """
        验证品牌页-本月推荐接口响应时长
        :uri : /front/p/homeBrand/getHomeBrandDetail
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.getHomeBrandDetail(brandId=brandId)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/homeBrand/getHomeBrandDetail 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def getHomeBrandDetailData(self,brandId=None):
        """
        验证品牌页-本月推荐接口响应数据
        :uri : /front/p/homeBrand/getHomeBrandDetail
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.getHomeBrandDetail(brandId=brandId)
        code = res.json()['code']
        assert code == 1,"/front/p/homeBrand/getHomeBrandDetail 校验接口存在响应数据code=1，校验失败,实际响应数据：\n%s" % res.text

    def getHomeBrandGoodsState(self,brandId=None):
        """
        品牌页-本月系列接口状态
        :uri : /front/p/homeBrand/getHomeBrandGoods
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.getHomeBrandGoods(brandId=brandId)
        state = res.status_code
        assert state == 200,"/front/p/homeBrand/getHomeBrandGoods 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def getHomeBrandGoodsTime(self,brandId=None):
        """
        品牌页-本月系列接口响应时长
        :uri : /front/p/homeBrand/getHomeBrandGoods
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.getHomeBrandGoods(brandId=brandId)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/homeBrand/getHomeBrandGoods 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def getHomeBrandGoodsData(self,brandId=None):
        """
        品牌页-本月系列接口响应数据
        :uri : /front/p/homeBrand/getHomeBrandGoods
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.getHomeBrandGoods(brandId=brandId)
        code = res.json()['code']
        assert code == 1,"/front/p/homeBrand/getHomeBrandGoods 校验接口响应数据code=1，校验失败,实际响应数据：\n%s" % res.text

    def intendedCustomerState(self,intendedId=None):
        """
        意向客户埋点接口状态
        :uri : /front/p/custom/intendedCustomer
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.intendedCustomer(intendedId=intendedId)
        state = res.status_code
        assert state == 200,"/front/p/custom/intendedCustomer 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def intendedCustomerTime(self,intendedId=None):
        """
        意向客户埋点接口响应时长
        :uri : /front/p/custom/intendedCustomer
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.intendedCustomer(intendedId=intendedId)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/custom/intendedCustomer 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def intendedCustomerData(self,intendedId=None):
        """
        意向客户埋点接口响应数据
        :uri : /front/p/custom/intendedCustomer
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.intendedCustomer(intendedId=intendedId)
        assert "data" in res.text,"/front/p/custom/intendedCustomer 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def sourceBySpuIdState(self,spuId=None):
        """
        商品素材接口状态
        :uri : /front/p/sourceBySpuId
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.sourceBySpuId(spuId=spuId)
        state = res.status_code
        assert state == 200,"/front/p/sourceBySpuId 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def sourceBySpuIdTime(self,spuId=None):
        """
        商品素材接口响应时长
        :uri : /front/p/sourceBySpuId
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.sourceBySpuId(spuId=spuId)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/sourceBySpuId 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def sourceBySpuIdData(self,spuId=None):
        """
        商品素材接口响应数据
        :uri : /front/p/sourceBySpuId
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.sourceBySpuId(spuId=spuId)
        assert "data" in res.text,"/front/p/sourceBySpuId 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def selectGoodState(self,spuKW=None):
        """
        首页搜索商品接口状态
        :uri : /front/p/newGoodsSpu/selectGoodsSpuList
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.selectGood(spuKW=spuKW)
        state = res.status_code
        assert state == 200,"/front/p/newGoodsSpu/selectGoodsSpuList 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def selectGoodTime(self,spuKW=None):
        """
        首页搜索商品接口响应时长
        :uri : /front/p/newGoodsSpu/selectGoodsSpuList
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.selectGood(spuKW=spuKW)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/front/p/newGoodsSpu/selectGoodsSpuList 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def selectGoodData(self,spuKW=None):
        """
        首页搜索商品接口响应数据
        :uri : /front/p/newGoodsSpu/selectGoodsSpuList
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.selectGood(spuKW=spuKW)
        assert "data" in res.text,"/front/p/newGoodsSpu/selectGoodsSpuList 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def personalInfoState(self):
        """
        个人信息接口状态
        :uri : /liveUser/getPersonalInfoByUserId
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.personalInfo()
        state = res.status_code
        assert state == 200,"/liveUser/getPersonalInfoByUserId 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def personalInfoTime(self):
        """
        个人信息接口响应时长
        :uri : /liveUser/getPersonalInfoByUserId
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.personalInfo()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/liveUser/getPersonalInfoByUserId 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def personalInfoData(self):
        """
        个人信息接口响应数据
        :uri : /liveUser/getPersonalInfoByUserId
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.personalInfo()
        assert "userName" in res.text,"/front/p/newGoodsSpu/selectGoodsSpuList 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def hotLiveRoomState(self):
        """
        直播热门列表状态
        :uri : /homePage/hotLiveRoom
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hotLiveRoom()
        state = res.status_code
        assert state == 200,"/homePage/hotLiveRoom 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def hotLiveRoomTime(self):
        """
        个人信息接口响应时长
        :uri : /homePage/hotLiveRoom
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hotLiveRoom()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/homePage/hotLiveRoom 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def hotLiveRoomData(self):
        """
        个人信息接口响应数据
        :uri : /homePage/hotLiveRoom
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hotLiveRoom()
        assert "coverUrl" in res.text,"/front/p/newGoodsSpu/selectGoodsSpuList 校验接口存在sellPrice数据，校验失败,实际响应数据：\n%s" % res.text

    def hpBannerState(self):
        """
        看直播页面banner接口状态
        :uri : /homePage/homePageBanner
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hpBanner()
        state = res.status_code
        assert state == 200,"/homePage/homePageBanner 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def hpBannerTime(self):
        """
        看直播页面banner接口响应时长
        :uri : /homePage/homePageBanner
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hpBanner()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/homePage/homePageBanner 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def hpBannerData(self):
        """
        看直播页面banner接口响应数据
        :uri : /homePage/homePageBanner
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hpBanner()
        code = res.json()['code']
        assert code == 0,"/homePage/homePageBanner 校验接口code=0,校验失败，实际响应数据：\n%s" % res.text

    def focusLiveState(self):
        """
        直播关注列表接口状态
        :uri : /homePage/focusLiveRoom
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.focusLiveRoom()
        state = res.status_code
        assert state == 200,"/homePage/focusLiveRoom 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def focusLiveTime(self):
        """
        直播关注列表接口响应时长
        :uri : /homePage/focusLiveRoom
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.focusLiveRoom()
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/homePage/focusLiveRoom 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def focusLiveData(self):
        """
        直播关注列表接口响应数据
        :uri : /homePage/focusLiveRoom
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.focusLiveRoom()
        code = res.json()['code']
        assert code == 0,"/homePage/focusLiveRoom 校验接口code=0,校验失败，实际响应数据：\n%s" % res.text

    def hpSearchState(self,key=None):
        """
        直播页面搜索接口状态
        :uri : /homePage/homePageSearch
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hpSearch(key=key)
        state = res.status_code
        assert state == 200,"/homePage/homePageSearch 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def hpSearchTime(self,key=None):
        """
        直播页面搜索接口响应时长
        :uri : /homePage/homePageSearch
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hpSearch(key=key)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/homePage/homePageSearch 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def hpSearchData(self,key=None):
        """
        直播页面搜索接口响应数据
        :uri : /homePage/homePageSearch
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.hpSearch(key=key)
        code = res.json()['code']
        assert code == 0,"/homePage/homePageSearch 校验接口code=0,校验失败，实际响应数据：\n%s" % res.text

    def liveOpenInfoState(self,userId=mrjbusC.getSaleUser()):
        """
        获取开播信息接口状态
        :uri: /liveRoom/getOnLiveOpenInfoVo
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.liveOpenInfo(userId=userId)
        state = res.status_code
        assert state == 200,"/liveRoom/getOnLiveOpenInfoVo 校验接口状态码为200，校验失败,实际状态码： %s" % state

    def liveOpenInfoTime(self,userId=mrjbusC.getSaleUser()):
        """
        获取开播信息接口响应时长
        :uri: /liveRoom/getOnLiveOpenInfoVo
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.liveOpenInfo(userId=userId)
        totalTime = res.elapsed.total_seconds()
        # print(totalTime)
        assert totalTime < 1,"/liveRoom/getOnLiveOpenInfoVo 校验接口响应时长小于1秒，校验失败,实际响应时长：%s" % totalTime

    def liveOpenInfoData(self,userId=mrjbusC.getSaleUser()):
        """
        获取开播信息接口响应数据
        :uri: /liveRoom/getOnLiveOpenInfoVo
        :author 露驿星程
        """
        reqC = Req_api()
        res = reqC.liveOpenInfo(userId=userId)
        code = res.json()['code']
        assert code == 0,"/liveRoom/getOnLiveOpenInfoVo 校验接口code=0,校验失败，实际响应数据：\n%s" % res.text

if __name__ == "__main__":
    pass
    # VerifyC = pre_mallHome()
    # VerifyC.liveOpenInfoData()